package cn.iocoder.yudao.module.system.controller.admin.mini.other.turnTable.dal.mysql.turntable;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.mini.other.turnTable.controller.admin.turntable.vo.TurntableExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.other.turnTable.controller.admin.turntable.vo.TurntablePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.other.turnTable.dal.dataobject.turntable.TurntableDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 转盘管理 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface TurntableMapper extends BaseMapperX<TurntableDO> {

    default PageResult<TurntableDO> selectPage(TurntablePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TurntableDO>()
                .betweenIfPresent(TurntableDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(TurntableDO::getName, reqVO.getName())
                .eqIfPresent(TurntableDO::getUrl, reqVO.getUrl())
                .eqIfPresent(TurntableDO::getType, reqVO.getType())
                .betweenIfPresent(TurntableDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(TurntableDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(TurntableDO::getSize, reqVO.getSize())
                .eqIfPresent(TurntableDO::getStatus, reqVO.getStatus())
                .orderByDesc(TurntableDO::getId));
    }

    default List<TurntableDO> selectList(TurntableExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TurntableDO>()
                .betweenIfPresent(TurntableDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(TurntableDO::getName, reqVO.getName())
                .eqIfPresent(TurntableDO::getUrl, reqVO.getUrl())
                .eqIfPresent(TurntableDO::getType, reqVO.getType())
                .betweenIfPresent(TurntableDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(TurntableDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(TurntableDO::getSize, reqVO.getSize())
                .eqIfPresent(TurntableDO::getStatus, reqVO.getStatus())
                .orderByDesc(TurntableDO::getId));
    }

}
